package com.ppc.ugo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ppc.ugo.dao.mapper.GoodAttrsMapper;
import com.ppc.ugo.dao.pojo.GoodAttrs;
import com.ppc.ugo.service.GoodAttrsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
@Slf4j
public class GoodAttrsServiceImpl implements GoodAttrsService {
    @Resource
    private GoodAttrsMapper goodAttrsMapper;

    @Override
    public void addGoodAttrs(GoodAttrs goodAttrs) {
        goodAttrsMapper.insert(goodAttrs);
        log.info("添加商品属性成功，商品id：{}", goodAttrs.getGoods_id());
    }

    @Override
    public List<GoodAttrs> selectByGid(Integer gid) {
        LambdaQueryWrapper<GoodAttrs> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(GoodAttrs::getGoods_id, gid);

        List<GoodAttrs> goodAttrs = goodAttrsMapper.selectList(queryWrapper);
        return goodAttrs;
    }
}
